<extend name="Public:base" />
<block name="header_js">

<script type="text/javascript">
    $(function(){
         
        //选中全部子级
        $('input[level=1]').click(function(){

            var checked = $(this).prop('checked');            
            var inputs = $(this).parents('.panel').find('.panel-body input');     
            if (checked) {
                inputs.prop('checked', true);
            }else {
                inputs.prop('checked', false);
            }
            
        });
        //选中全部子级
        $('input[level=2]').click(function(){

            var checked = $(this).prop('checked');            
            var parent = $(this).parents('.panel:eq(0)'); 
            var topParent = parent.parents('.panel:eq(0)');    
            if (checked) {
                parent.find('.panel-body input').prop('checked', true);
                topParent.find('input[level=1]').prop('checked', true);
            }else {
                parent.find('.panel-body input').prop('checked', false);
                topParent.find('input[level=1]').prop('checked', false);
            }
            
        });

        //选中父级
        $('input[level=3]').click(function(){

            var checked = $(this).prop('checked');            
            var parent = $(this).parents('.panel:eq(0)');
            var topParent = parent.parents('.panel:eq(0)');  
            if (checked) {
                parent.find('.panel-heading input').prop('checked', true);
                topParent.find('input[level=1]').prop('checked', true);
            }
            
        });



    });
 
</script>
</block>

<block name="content">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em> 
            {$type}         
            </h3> 
        </div>
        
    </div>

    <div class="row margin-botton">
        <div class="col-lg-12">
            <div class="btn-group btn-group-md">           
                <button class="btn btn-primary" type="button" onclick="goUrl('{:U('role')}')"><em class="glyphicon glyphicon-chevron-left"></em> 返回</button>
                <button class="btn btn-info" type="button" onclick="doGoSubmit('{:U('access')}', 'formAccess')"><em class="glyphicon glyphicon-saved"></em> 更新权限</button>
            </div>
        </div>
    </div>


    <div class="row">
        <div class="col-lg-12">
            <form method="post" action="" id="formAccess">
            <input type="hidden" name="rid" value="{$rid}"/>
            <volist name="node" id="vo">
                <div class="panel panel-info">
                    <div class="panel-heading">
                        <div class="row">
                                <div class="col-xs-8">
                                    <h3 class="panel-title">
                                    <input type="checkbox" name="access[]" value="{$vo.id}_{$vo.level}" level="1" <if condition="$vo['access']">checked="checked"</if>/> {$vo.title}</h3>
                                </div>
                        </div>
                        
                    </div>
                    <div class="panel-body xyh-panel-body">
                            <volist name="vo['child']" id="vo2">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <div class="row">
                                                <div class="col-xs-8">
                                                    <h3 class="panel-title">
                                                    <input type="checkbox" name="access[]" value="{$vo2.id}_{$vo2.level}" level="2" <if condition="$vo2['access']">checked="checked"</if>/> {$vo2.title}</h3>
                                                </div>
                                        </div>
                                        
                                    </div>
                                    <div class="panel-body">
                                            <volist name="vo2['child']" id="vo3"> 
                                                <label class="checkbox-inline">                    
                                                    <input type="checkbox" name="access[]" value="{$vo3.id}_{$vo3.level}" level="3" <if condition="$vo3['access']">checked="checked"</if>/>                
                                                    <span class="label label-primary">{$vo3.title}</span> 
                                                </label> &nbsp;&nbsp;
                                            </volist>
                                    </div>
                                </div>                                
                            </volist>
                    </div>
                </div>
            
            </volist>
            </form>

        </div>
    </div>

</block>